package com.example.houduan.Service.Impl;

import com.example.houduan.Mapper.MaterialMapper;
import com.example.houduan.Pojo.Material;
import com.example.houduan.Service.MaterialService;
import com.example.houduan.Utils.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MaterialServiceImpl implements MaterialService {

    @Autowired
    MaterialMapper materialMapper;

    @Override
    public PageModel getMaterialPage(int num, int size) {
        int count = materialMapper.selectMaterialCount();
        PageModel pm = new PageModel(num, count, size);
        pm.setList(materialMapper.selectMaterialLimit((num - 1) * size, size));
        return pm;
    }

    @Override
    public List<Material> getMaterialByConditions(Integer meterial_id, String title, String policy_title) {
        return materialMapper.selectMaterialByConditions(meterial_id, title, policy_title);
    }

    @Override
    public int addMaterial(Material material) {
        return materialMapper.insertMaterial(material);
    }

    @Override
    public int deleteMaterial(int meterial_id) {
        return materialMapper.deleteMaterial(meterial_id);
    }

    @Override
    public int updateMaterial(Material material) {
        return materialMapper.updateMaterial(material);
    }
} 